package cn.zc.curriculum.service.controller.admin;

import cn.tools.core.VO.PageVO;
import cn.tools.core.base.R;
import cn.zc.curriculum.entity.Dto.InterfaceManagerDto;
import cn.zc.curriculum.service.service.InterfaceManagerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 * 菜单接口
 * @author keno
 * @since 2022-02-19
 */
@Api(tags = "后台轮播图，导航栏，友链管理接口")
@RestController
@RequestMapping("/curriculum")
public class AdminInterfaceManagerController {

    @Resource
    private InterfaceManagerService interfaceManagerService;

    /**
     * 创建数据
     * @param interfaceManagerDto
     * @return
     */
    @ApiOperation(value = "创建轮播图，或者导航栏，以及友链")
    @PostMapping("/admin/create/InterfaceManager")
    private R createInterfaceManager(@RequestBody InterfaceManagerDto interfaceManagerDto){
        interfaceManagerService.createInterfaceManager(interfaceManagerDto);
        return R.success();
    }

    /**
     * 修改数据
     * @param interfaceManagerDto
     * @return
     */
    @ApiOperation(value = "修改轮播图，或者导航栏，以及友链")
    @PutMapping("/admin/upload/InterfaceManager")
    private R uploadInterfaceManager(@RequestBody InterfaceManagerDto interfaceManagerDto){
        interfaceManagerService.uploadInterfaceManager(interfaceManagerDto);
        return R.success();
    }

    /**
     * 删除数据
     * @param id
     * @return
     */
    @ApiOperation(value = "删除轮播图，或者导航栏，以及友链")
    @DeleteMapping("/admin/delete/InterfaceManager")
    private R deleteInterfaceManager(String id){
        interfaceManagerService.deleteInterfaceManager(id);
        return R.success();
    }


    /**
     * 根据条件查询数据
     * @param id
     * @return
     */
    @ApiOperation(value = "根据id或者类型查询轮播图，或者导航栏，以及友链")
    @GetMapping("/admin/find/InterfaceManager")
    private R<Object> findInterfaceManager(PageVO pageVO, String id, Integer type){
        List<InterfaceManagerDto> interfaceManagerDto = interfaceManagerService.findInterfaceManager(pageVO,id,type);
        return R.success(interfaceManagerDto);
    }


}
